package com.zlq.cn.controller.sign.lovers;


import com.zlq.cn.api.SignApiResult;
import com.zlq.cn.dto.param.lovers.LoversBindUserParam;
import com.zlq.cn.dto.vo.SignCommonParam;
import com.zlq.cn.entity.User;
import com.zlq.cn.service.lovers.LoversBindUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhoucl
 * @since 2022-05-08
 */
@Api(tags = "小情侣-绑定")
@RestController
@RequestMapping("/lovers/bind/user")
public class LoversBindUserController {

    @Resource
    private LoversBindUserService loversBindUserService;

    @ApiOperation("绑定")
    @PostMapping("/bind")
    public SignApiResult<String> bind(@Valid @RequestBody LoversBindUserParam bindUserParam) {
        loversBindUserService.bind(bindUserParam.getInvitationCode());
        return SignApiResult.resultSuccess("绑定成功");
    }

    @ApiOperation("获取绑定")
    @PostMapping("/get")
    public SignApiResult<List<User>> get(@Valid @RequestBody SignCommonParam param) {
        return SignApiResult.resultSuccess(loversBindUserService.getBind());
    }
}

